﻿@{
    Layout = null;
}
@* 项目：注册页面
    作者：程刚
    日期：8.4
*@

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>注册</title>
    <link rel="shortcut icon" href="~/img/favicon.ico" />
    <link rel="bookmark" href="~/img/favicon.ico" />
    <link href="~/BootstrapSouce/css/bootstrap.min.css" title="" rel="stylesheet" />
    <link title="orange" href="~/css/login.css" rel="stylesheet" type="text/css" />
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
</head>
<body style="background-color:#0094ff">
    <div style="height:1px;"></div>
    <div class="login">
        <header>
            <h1>注册</h1>
        </header>
        <div class="sr">
            <form >
                @*<div class="name">
                <label>
                    <i class="sublist-icon glyphicon glyphicon-user"></i>
                </label>
                <input type="text" placeholder="这里输入用户名" class="name_inp"  >
            </div>*@
                <div class="name">
                    <label>
                        <i class="sublist-icon glyphicon glyphicon-leaf"></i>
                    </label>
                    <input type="text" placeholder="这里输入账号" class="name_inp" id="txtName">

                </div>
                <div class="name">
                    <label>
                        <i class="sublist-icon glyphicon glyphicon-pencil"></i>
                    </label>
                    <input type="password" placeholder="这里输入密码" class="name_inp" id="txtPwd"    >
                </div>
                <div class="name">
                    <label>
                        <i class="sublist-icon glyphicon glyphicon-phone"></i>
                    </label>
                    <input type="text" placeholder="手机号" class="name_inp" id="UserPhone">
                </div>
                <div class="name">
                    <label>
                        <i class="sublist-icon glyphicon glyphicon-earphone"></i>
                    </label>
                    <input type="text" placeholder="手机验证码" class="name_inp" id="mobile"><span id="hui" ></span>
                    <input type="button" onclick="Request()" value="点击获取" class="btn btn-default"/>
                </div>
                <input type="button" class="dl" style="margin-top:45px" onclick="Regist2()" value="注册" />
                <input type="button" class="dl" style="margin-top:45px"  value="返回" onclick="location.href='/Home/LoginPage'" />
         
            </form>
        </div>
    </div>
</body>
</html>
<script>
    function Request() {
        var UserPhone = $("#UserPhone").val();
        $.ajax({
            url: "/Home/PhoneYzm",
            dataType: "json",
            type: "post",
            data: { mobiles: UserPhone },
            success: function (obj) {
       
                if (obj["code"] == 2) {
                    $("#hui").html("发送成功");
                    return;
                }
                else {
                    $("#hui").html("发送失败");
                }
            }
        })
    }
    function Regist2() {
        var UserName=$("#txtName").val();
        var UserPwd=$("#txtPwd").val();
        var UserPhone = $("#UserPhone").val();
        var mobile = $("#mobile").val();
        if (UserName == "" || UserPwd == "" || UserPhone == "" || mobile == "")
        {
            alert("输入信息不能为空");
        }
        else {
            $.ajax({
                type: "post",
                url: "/Home/Register",
                data: { UserName: UserName, UserPwd: UserPwd, UserPhone: UserPhone, mobile: mobile },
                success: function (i) {
                    if (i == -5) {
                        alert("用户名已存在，请重新输入！")
                    }
                    else {
                        if (i == -3) {
                            alert("验证码输入错误")
                            return;
                        }
                        else {
                            if (i == 1) {
                                alert("注册成功");
                                location.href = '/Home/LoginPage';
                                return;

                            }
                            else {
                                alert("注册失败")
                                return;
                            }
                        }
                    }
                }
            })
        }
    }

</script>

